
/**
 * @ProjectName: 
 * @Copyright: 2014 lisheng Co., Ltd. All Right Reserved.
 * @address: toughheart@163.com
 * @date: 2016年5月1日 下午1:20:29
 * @Description: 本内容未经本人允许禁止使用、转发.
 */
 
package com.ls.fw.web.file.config;

import javax.servlet.http.HttpServletRequest;

import com.ckfinder.connector.configuration.ConfigurationFactory;
import com.ckfinder.connector.configuration.ConfigurationPathBuilder;
import com.ckfinder.connector.configuration.IConfiguration;
import com.ckfinder.connector.utils.PathUtils;
import com.ls.fw.commons.spring.SpringContextHolder;
import com.ls.fw.web.file.support.config.IFileConfiguration;


/**
 * 
 * @author lisheng
 * @date 2016年5月1日 下午1:20:29
 * @version V1.0 
 */
public class FwConfigurationPathBuilder extends ConfigurationPathBuilder {
	@Override
	public String getBaseUrl(final HttpServletRequest request) {
		String baseURL = null;
		try {
			IConfiguration conf = ConfigurationFactory.getInstace().getConfiguration();
			baseURL = conf.getBaseURL();
		} catch (Exception e) {
			baseURL = null;
		}
		if (baseURL == null || baseURL.equals("")) {
			IFileConfiguration fileConfiguration  =  SpringContextHolder.getBean(IFileConfiguration.class);
			baseURL = fileConfiguration.getBaseUrl(request);
		}
		if (baseURL == null || baseURL.equals("")) {
			baseURL = super.getBaseUrl(request);
		}

		return PathUtils.addSlashToBeginning(PathUtils.addSlashToEnd(baseURL));
	}
}
